<?php

namespace App\Console\Commands;

use App\Services\OpenAIService;
use Illuminate\Console\Command;
use Exception;

class OpenAI extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'app:open-ai';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Execute the console command.
     */
    public function handle()
    {
        $model = "gpt-4"; //gpt-3.5-turbo, gpt-4
        $message = [[
            'role' => 'user',
            'content' => "三加三再加三等于多少"
        ]];

        try {
            $text = OpenAIService::chat($message, $model);
            $this->info($text);
        } catch (Exception $e) {
            $this->error($e->getMessage());
        }
    }
}
